import React from 'react';
import './index.less';
import PropTypes from 'prop-types';
import {Toast,Modal,Badge,Icon,Result} from 'antd-mobile';
import FootTabBar from 'COMPONENT/FootTabBar';
import CommonHeader from 'COMPONENT/CommonHeader';
import {cellphoneTest,getPhoneCode} from 'UTIL/validation';

import mineService from 'SERVICE/mineService';
import {getLocalData,canvasDataURL,phoneSystem} from 'UTIL/commonUtil';
import { devUrl} from 'SERVICE/xhr/config';

const alert = Modal.alert;

export default class My extends React.Component {
    static contextTypes = {
        router: PropTypes.object.isRequired
    }
    constructor(props) {
        super(props);
        this.state = {
          infomation: {},
          template:'defaultTemplate',
          version:'false',
          src:"",
          versionNum:''
        }
    }

    componentWillMount() {
        mineService.getInformations((res)=>{
            //alert(1)
            let info ;
            if(res!=''){
                info = res;
            }
            this.setState({infomation: info,src:info.photoUrl});
        })
        let type = phoneSystem();
        let setData = {};
        
        let version = localStorage.getItem('version');
    	setData['versionNum'] = version;
        mineService.compareVersions(type).then((res)=>{
            let versions;
            //code为1  有新版本，有返回url(更新地址)；
            if(res.code==1){
            	setData['version'] = "true";
            	//setData['downloadUrl'] = res.url || '';
            }else{
            	setData['version'] = "false";
            }
            //this.setState({versionNum: version,version: versions});
            this.setState({
            	...setData
            });
        })
        //alert(localStorage.getItem('userAuthToken'))
        //alert(localStorage.getItem('imei')+'imei')

    }

	
	jumpToAccountSecret = () => {
		native.call({
        	'fun':'openAccountList'
    	})
	}
	
	backs = () => {
	 	this.context.router.push({
            pathname: '/Home'
        })
	 	return false;
	}
	
    render() {
       
       
	   	let scanResult = localStorage.getItem('scanResult') || "所提交内容已成功完成验证";

        return(
            <div className="result-example scanResult">

				<div className='header' onClick={this.backs} style={{background:'#fff'}}>
		 		    <img  onClick={this.backs} src="./imgs/iconfont-6.png" style={{
			    	    height: '.4rem',
					    marginTop: '.25rem',
					    marginLeft: '.2rem'
		
		 		    }} />
      	
	     		    <span onClick={this.backs} style={{color:'transparent',
	     		        color: 'transparent',
					    height: '.9rem',
					    display: 'inline-block',
					    marginTop: '-0.3rem'}}>返回</span>
 		    		<div className = "loginStateHeader" onClick={this.backs}></div>
					<div className="header_title" style={{
					    color: '#333',
					    textAlign: 'left',
					    marginLeft: '.8rem'
					}}>
	
					扫描成功
	
					</div>

				</div>
	            <div className="sub-title">扫描成功</div>
				<Result
				    img={<Icon type="check-circle" className="spe" style={{ fill: '#1F90E6' }} />}
				    title="扫描成功"
				    message={scanResult}
				/>

            </div>
        );
    }
}